//1)导入服务模块http
let http=require('http')

let url=require('url')


//2)创建服务
const server=http.createServer()

server.on('request',(req,res)=>{
    const urlObj=url.parse(req.url,ture)
    //跨域
res.writeHead(200,{
    //跨域
"access-control-allow-origin":"*",//允许所有域都可以
"content-type":"application/json;charset=utf-8"

})

if(urlObj.pathname==='/api/getInfo'){
HTMLOptGroupElement()
}else{
    res.end('404')
}

})
https://www.maoyan.com/
function httpget(){
    let data=''
https.get('https://www.maoyan.com/',(res)=>{

    res.on("data",()=>{
        return res.end(spider(data))
        //监听response状态data，就是还在接收数据
    })

res.on("end",()=>{//同上，end接收完成})
console.log(data)

})

})
}




server.listen(80,()=>(
    console.log('http://127.0.0.1')
))